#!/usr/bin/env python
import time
import random
import Seven_Segment_Display as display

display.init()
display.description()

print('\ntesting 7-segment display')
display.test()

print('\ncounting digit 0 to 3 from 0 to 9')
for i in range (0,4):
  for j in range (0,10):
    display.set_digit(i,j)
    time.sleep(0.1)
time.sleep(0.5)

print('\ncounting display from 0 to 9999')
for i in range (0,10000):
  display.set_display(i)

# displaying min:sec
print('\ndisplaying time')
print('press button to display seconds')
while True:
  s = time.localtime().tm_sec
  m = time.localtime().tm_min
  h = time.localtime().tm_hour
  if not (display.get_switch()):
    display.set_double_digit(0,m)
    display.set_double_digit(1,h)
  else:
    display.set_double_digit(0,s)
    display.set_digit(2,10)
    display.set_digit(3,10)
  time.sleep(0.25)
